Trò chơi đua xe động vật trong UNITY Engine
114.852 lượt xem;
- InterpolationSwing.cs
- Interpolations /
- Bapk /
- Scripts /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4 public class InterpolationSwing : InterpolationProcess {
5 private float scale;
6
7 public InterpolationSwing(float scale)
8 {
9 this.scale = scale;
10 }
11
12 public override float apply(float a)
13 {
14 if (a <= 0.5f)
15 {
16 a *= 2;
17 return a * a * ((scale + 1) * a - scale) / 2;
18 }
19 a--;
20 a *= 2;
21 return a * a * ((scale + 1) * a + scale) / 2 + 1;
22 }
23 }
2 using System.Collections;
3
4 public class InterpolationSwing : InterpolationProcess {
5 private float scale;
6
7 public InterpolationSwing(float scale)
8 {
9 this.scale = scale;
10 }
11
12 public override float apply(float a)
13 {
14 if (a <= 0.5f)
15 {
16 a *= 2;
17 return a * a * ((scale + 1) * a - scale) / 2;
18 }
19 a--;
20 a *= 2;
21 return a * a * ((scale + 1) * a + scale) / 2 + 1;
22 }
23 }